---
title: "Replication of: Priming Partisan Identities and Support for Political Violence"
author: "Suhan Kacholia and Fabian G. Neuner"
date: "4/20/2022"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, message = F, warning=F)
```
# Overview

This Rmarkdown file replicates the article "Priming Partisan Identities and Support for Political Violence” by Suhan Kacholia and Fabian G. Neuner, published in *Frontiers in Political Science*.

# Data and Packages

```{r}
library(rmarkdown)
library(tidyverse)
library(reshape2)
library(coefplot)
library(interplot)
library(jtools)
library(psych)
library(modelsummary)
library(ggpubr)
library(kableExtra)

df <- read_csv("kacholia_neuner_replication_dataset.csv")
```

#Data cleaning

```{r}
#Data cleaning, exclude true Independents
df <- filter(df, !is.na(PartyID))

#Make factor variables
df$Condition <- as.factor(df$Condition)
df <- df %>%
  mutate(Condition = relevel(Condition, ref = "Control"))
df$race <- as.factor(df$race)
df$educ <- as.factor(df$educ)
df$gender <- as.factor(df$gender)
levels1<-c(1,2,2,2,2)
levels2<-c(1,1,1,2,2,2)
df$race <- factor(levels1[df$race])
df$educ <- factor(levels2[df$educ])

#New scale variables for means
df$pv_D_mean <- rowMeans(subset(df, select = c(pv1_D:pv4_D)), na.rm = TRUE)
df$pv_R_mean <- rowMeans(subset(df, select = c(pv1_R:pv4_R)), na.rm = TRUE)
df$pv_mean <- rowMeans(subset(df, select = c(pv1_D:pv4_R)), na.rm = TRUE)
df$pv_mean2 <- rowMeans(subset(df, select = c(viol1:viol3RepDem)), na.rm = TRUE)
df$dd_mean <- rowMeans(subset(df, select = c(dd1:dd12)), na.rm = TRUE)
df$amId_mean <- rowMeans(subset(df, select = c(amId_1:amId_5)), na.rm = TRUE)
df$pos_mean <- rowMeans(subset(df, select = c(pos1:pos8)), na.rm = TRUE)
df$neg_mean <- rowMeans(subset(df, select = c(neg1:neg8)), na.rm = TRUE)

#Exclude "Don't Know" from policy questions
if(df$policy1 == 6) {df$policy1 = NA}
if(df$policy2 == 6) {df$policy2 = NA}
if(df$policy3 == 5) {df$policy3 = NA}
if(df$policy4 == 6) {df$policy4 = NA}
if(df$policy5 == 6) {df$policy5 = NA}

# Negativity Bias variable

#Key:
#Economy - 2&3
#Env. - 2&3
#Health - 3&4
#Politics - 1&2
#Foreign - 1&3

df$neg.bias <- 0

for (row in 1:nrow(df)) {
  
  econ <- df[row, "nbns_economy"]
  if(!is.na(econ)) {
    if ((econ == 2) | (econ == 3)) {
      df[row, "neg.bias"] <- df[row, "neg.bias"] + 1
    }
  }
  
  env <- df[row, "nbns_environment"]
  if(!is.na(env)) {
    if ((env == 2) | (env == 3)) {
      df[row, "neg.bias"] <- df[row, "neg.bias"] + 1
    }
  }
  
  heal <- df[row, "nbns_health"]
  if(!is.na(heal)) {
    if ((heal == 3) | (heal == 4)) {
      df[row, "neg.bias"] <- df[row, "neg.bias"] + 1
    }
  }
  
  pol2 <- df[row, "nbns_politics"]
  if(!is.na(pol2)) {
    if ((pol2 == 1) | (pol2 == 2)) {
      df[row, "neg.bias"] <- df[row, "neg.bias"] + 1
    }
  }
  
  foreign <- df[row, "nbns_foreign"]
  if(!is.na(foreign)) {
    if ((foreign == 1) | (foreign == 3)) {
      df[row, "neg.bias"] <- df[row, "neg.bias"] + 1
    }
  }
}

rm(env, pol2, econ, heal, foreign)

# Instrumental Partisanship variables
df$policy3 <- 5 - df$policy3
df$policy5 <- 6 - df$policy5
policies <- c("policy1", "policy2", "policy3", "policy4", "policy5")

df$policy_mean <- rowMeans(subset(df, select = policies), na.rm = TRUE)

policies[c(-3)]

for (row in 1:nrow(df)) {
  for (column in policies[c(-3)]) {
    policy <-  df[row, column]
    new <- paste(column, "folded", sep = "")
    if (!is.na(policy)) {
    if ((policy == 3)) {
      df[row, new] <- 0
    }
    if ((policy == 2) | (policy == 4)) {
      df[row, new] <- 1
    }
    if ((policy == 1) | (policy == 5)) {
      df[row, new] <- 2
    }
    else {
      df[row, new] <- NA
    }
    }
  }
}

for (row in 1:nrow(df)) {
  policy3 <-  df[row, "policy3"]
  if(!is.na(policy3)) {
  if ((policy3 == 2) | (policy3 == 3)) {
    df[row, "policy3folded"] <- 1
  }
  if ((policy3 == 1) | (policy3 == 4)) {
    df[row, "policy3folded"] <- 2
  }
  }
}

policies_folded <- c("policy1folded", "policy2folded", "policy3folded", "policy4folded", "policy5folded")
df$policyfolded_mean <- rowMeans(subset(df, select = policies_folded), na.rm = TRUE)


#Partisan strength variable
df$strength <- df$pid0

for (row in 1:nrow(df)) {
  rep <- df[row, "pidRep"]
  dem <- df[row, "pidDem"]
  ind <- df[row, "pidInd"]
  if (!is.na(rep)) {
    df[row, "strength"] = 4 - rep
  }
  if (!is.na(dem)) {
    df[row, "strength"] = 4 - dem
  }
  if (!is.na(ind)) {
    df[row, "strength"] = 1
  }
}

# Function to normalize all scales from 0-1
normalize <- function(dataframe, column, column2) {
  max.val <- max(dataframe[column], na.rm = TRUE)
  min.val <- min(dataframe[column], na.rm = TRUE)
  for (row in 1:nrow(dataframe)) {
    value <- dataframe[row, column]
    if (!is.na(value)) {
      dataframe[row, column2] <- ((value - min.val) / (max.val - min.val))
    }
  }
  return(dataframe)
}

# Normalize all scales from 0-1
df <- normalize(df, "pv_mean", "pv_scaled")
df <- normalize(df, "pv_mean2", "pv_scaled2")
df <- normalize(df, "dd_mean", "dd_scaled")
df <- normalize(df, "amId_mean", "amId_scaled")
df <- normalize(df, "pos_mean", "pos_scaled")
df <- normalize(df, "neg_mean", "neg_scaled")
df <- normalize(df, "policy_mean", "policy_scaled")
df <- normalize(df, "neg.bias", "neg_bias_scaled")
df <- normalize(df, "strength", "strength_scaled")
df <- normalize(df, "policyfolded_mean", "policyfolded_scaled")
```

# Manuscript

###Models
```{r}

#Linear Regressions of political violence support on conditions and controls
fit <- lm(pv_scaled ~ Condition, data = df)
fit2 <- lm(pv_scaled2 ~ Condition, data = df)
fitAll <- lm(pv_scaled ~ Condition + strength_scaled + age +
                     gender + race + educ + PartyID + dd_scaled + neg_bias_scaled, data = df)

fitAll2 <- lm(pv_scaled2 ~ Condition + strength_scaled + age +
                      gender + race + educ + PartyID + dd_scaled + neg_bias_scaled, data = df)

#Linear Regressions including interactions between conditions and party ID, party strength,  dark triad, and negativity bias variables

interfit_party <- lm(pv_scaled ~ (Condition * PartyID) + strength_scaled + age +
                        gender + race + educ + dd_scaled + neg_bias_scaled, data = df)
interfit_party2 <- lm(pv_scaled2 ~ (Condition * PartyID) + strength_scaled + age +
                        gender + race + educ + dd_scaled + neg_bias_scaled, data = df)
interfit_strength <- lm(pv_scaled ~ (Condition * strength_scaled) + PartyID + age +
                        gender + race + educ + dd_scaled + neg_bias_scaled, data = df)
interfit_strength2 <- lm(pv_scaled2 ~ (Condition * strength_scaled) + PartyID + age +
                           gender + race + educ + dd_scaled + neg_bias_scaled, data = df)
interfit_dd <- lm(pv_scaled ~ (Condition * dd_scaled) + PartyID + age +
                           gender + race + educ + strength_scaled + neg_bias_scaled, data = df)
interfit_dd2 <- lm(pv_scaled2 ~ (Condition * dd_scaled) + PartyID + age +
                           gender + race + educ + strength_scaled + neg_bias_scaled, data = df)
interfit_negbias <- lm(pv_scaled ~ (Condition * neg_bias_scaled) + PartyID + age +
                     gender + race + educ + strength_scaled + dd_scaled, data = df)
interfit_negbias2 <- lm(pv_scaled2 ~ (Condition * neg_bias_scaled) + PartyID + age +
                     gender + race + educ + strength_scaled + dd_scaled, data = df)

#Secondary analysis, using treatment as moderator

df$amer_con <- df$pos_con <- df$neg_con <- df$ins_con <- df$cont_con <- 0
for (row in 1:nrow(df)) {
  con <- df[row, "Condition"]
  if (!is.na(con)) {
    if (con == "American") {
      df[row, "amer_con"] = 1
    }
    if (con == "Positive") {
      df[row, "pos_con"] = 1
    }
    if (con == "Negative") {
      df[row, "neg_con"] = 1
    }
    if (con == "Instrumental") {
      df[row, "ins_con"] = 1
    }
    if (con == "Control") {
      df[row, "cont_con"] = 1
    }
  }
}

am_fit <- lm(amId_scaled ~ amer_con, data = df)
pos_fit <- lm(pos_scaled ~ pos_con, data = df)
neg_fit <- lm(neg_scaled ~ neg_con, data = df)
ins_fit <- lm(policyfolded_scaled ~ ins_con, data = df)

am_fit_2 <- lm(amId_scaled ~ amer_con + PartyID + strength_scaled, data = df)
pos_fit_2 <- lm(pos_scaled ~ pos_con + PartyID + strength_scaled, data = df)
neg_fit_2 <- lm(neg_scaled ~ neg_con + PartyID + strength_scaled, data = df)
ins_fit_2 <- lm(policyfolded_scaled ~ ins_con + PartyID + strength_scaled, data = df)

models2 <- list("American Identity" = am_fit, 
                "Positive Partisan Identity" = pos_fit, 
                "Negative Partisan Identity" = neg_fit,
                "Instrumental Partisan Identity" = ins_fit)

models2b <- list("American Identity" = am_fit_2, 
                "Positive Partisan Identity" = pos_fit_2, 
                "Negative Partisan Identity" = neg_fit_2,
                "Instrumental Partisan Identity" = ins_fit_2)

#Subsetting by condition

american <- filter(df, Condition == "American")
instrumental <- filter(df, Condition == "Instrumental")
negative <- filter(df, Condition == "Negative")
positive <- filter(df, Condition == "Positive")

amer_fit_2 <- lm(pv_scaled ~ amId_scaled, data = american)
ins_fit_2 <- lm(pv_scaled~ policyfolded_scaled, data = instrumental)
neg_fit_2 <- lm(pv_scaled ~ neg_scaled, data = negative)
pos_fit_2 <- lm(pv_scaled ~ pos_scaled, data = positive)
neg.bias_fit2 <- lm(pv_scaled ~ neg_bias_scaled, data = df)

amer_fit_2ANES <- lm(pv_scaled2 ~ amId_scaled, data = american)
ins_fit_2ANES <- lm(pv_scaled2 ~ policyfolded_scaled, data = instrumental)
neg_fit_2ANES <- lm(pv_scaled2 ~ neg_scaled, data = negative)
pos_fit_2ANES <- lm(pv_scaled2 ~ pos_scaled, data = positive)

amer_fit_2control <- lm(pv_scaled ~ amId_scaled + age +
                          gender + race + educ + PartyID, data = american)
ins_fit_2control <- lm(pv_scaled ~ policyfolded_scaled + age +
                         gender + race + educ + PartyID, data = instrumental)
neg_fit_2control <- lm(pv_scaled ~ neg_scaled + age +
                         gender + race + educ + PartyID, data = negative)
pos_fit_2control <- lm(pv_scaled ~ pos_scaled + age +
                         gender + race + educ + PartyID, data = positive)

amer_fit_2ANEScontrol <- lm(pv_scaled2 ~ amId_scaled + age +
                              gender + race + educ + PartyID, data = american)
ins_fit_2ANEScontrol <- lm(pv_scaled2 ~ policyfolded_scaled + age +
                             gender + race + educ + PartyID, data = instrumental)
neg_fit_2ANEScontrol <- lm(pv_scaled2 ~ neg_scaled + age +
                             gender + race + educ + PartyID, data = negative)
pos_fit_2ANEScontrol <- lm(pv_scaled2 ~ pos_scaled + age +
                             gender + race + educ + PartyID, data = positive)

models3 <- list("American Identity" = amer_fit_2ANES, 
                "Instrumental Partisan Identity" = ins_fit_2ANES, 
                "Negative Partisan Identity" = neg_fit_2ANES,
                "Positive Partisan Identity" = pos_fit_2ANES,
                "American Identity" = amer_fit_2, 
                "Instrumental Partisan Identity" = ins_fit_2, 
                "Negative Partisan Identity" = neg_fit_2,
                "Positive Partisan Identity" = pos_fit_2)

models3control <- list("American Identity" = amer_fit_2ANEScontrol, 
                       "Instrumental Partisan Identity" = ins_fit_2ANEScontrol, 
                       "Negative Partisan Identity" = neg_fit_2ANEScontrol,
                       "Positive Partisan Identity" = pos_fit_2ANEScontrol,
                       "American Identity" = amer_fit_2control, 
                       "Instrumental Partisan Identity" = ins_fit_2control, 
                       "Negative Partisan Identity" = neg_fit_2control,
                       "Positive Partisan Identity" = pos_fit_2control)
```

# Plots

```{r}

# Figure 1: Correlates of Political Violence

df_long_pv <- subset(filter(df, Condition == "Control"), select = c("pv_scaled", "pv_scaled2"))
df_long_pv <- melt(df_long_pv)

df_long_cor <- rename(df, "Partisan Strength" = "strength_scaled", "Dark Triad Score" = "dd_scaled", "Negativity Bias" = "neg_bias_scaled")
df_long_cor <- subset(df_long_cor, select = c("Partisan Strength", "Dark Triad Score", "Negativity Bias", "pv_scaled", "pv_scaled2"))
df_long_cor <- melt(df_long_cor, id.vars = c("pv_scaled", "pv_scaled2"))

a <- ggplot(df_long_cor, aes(x = value, y = pv_scaled2)) +
  geom_smooth(method = "lm") +
  facet_wrap(~variable) +
  labs(x = "Score", y = "Support for Political Violence (ANES Questions)") +
  theme(axis.title=element_text(size=7))

b <- ggplot(df_long_cor, aes(x = value, y = pv_scaled)) +
  geom_smooth(method = "lm") +
  facet_wrap(~variable) +
  labs(x = "Score", y = "Support for Political Violence (Kalmoe & Mason Questions)") +
  theme(axis.title=element_text(size=7))

comb1 <- ggarrange(a, b, nrow = 2)

# Produce Figure 1
comb1


# Figure 2: Treatment Effect Plot

fit.df1 <- as.data.frame(summary(fit)[["coefficients"]])
fit.df2 <- as.data.frame(summary(fit2)[["coefficients"]])
fit.df1$variable <- rownames(fit.df1)
fit.df2$variable <- rownames(fit.df2)
fit.df1 <- fit.df1[!(row.names(fit.df1) %in% "(Intercept)"), ]
fit.df2 <- fit.df2[!(row.names(fit.df2) %in% "(Intercept)"), ]
fit.df1$variable <- c("American", "Instrumental", "Negative", "Positive")
fit.df2$variable <- c("American", "Instrumental", "Negative", "Positive")

combined <- (rbind(fit.df1, fit.df2))
rownames(combined) <- 1:8
combined$df <- c(rep("Support for Political Violence (Kalmoe & Mason Questions)",4), rep("Support for Political Violence (ANES Questions)", 4))

treatplot <- ggplot(combined) + 
  geom_point(aes(x = variable, y = Estimate)) +
  geom_segment(aes(x = variable, xend = variable, 
                   y = Estimate - (2 * `Std. Error`),
                   yend = Estimate + (2 * `Std. Error`))) +
  geom_hline(yintercept = 0) +
  coord_flip() +
  labs(x = "Condition") +
  facet_wrap(~ df)

# Produce Figure 2
treatplot

# Appendix Figures

# Figure A1: DV Distributions

y <- ggplot(df, aes(x = pv_scaled2)) +
  geom_bar(aes(y = (..count..)/sum(..count..))) +
  labs(x = "Support for Political Violence (ANES Questions)", y = "Proportion of Respondents")

x <- ggplot(df, aes(x = pv_scaled)) +
  geom_bar(aes(y = (..count..)/sum(..count..))) +
  labs(x = "Support for Political Violence (Kalmoe & Mason Questions)", y = "Proportion of Respondents")

comb2 <- ggarrange(y, x)

# Produce Figure A1
comb2

# Figures A2-A4: Heterogeneous Effects

negplot <- interplot(interfit_negbias, var1 = "Condition", var2 = "neg_bias_scaled", hist = TRUE, facet_labs = c("American Condition", "Instrumental Condition", "Negative Condition", "Positive Condition")) +
  xlab("Negativity Bias Score") +
  ylab("Kalmoe & Mason Questions") +
  geom_hline(yintercept=0, linetype="dashed") +
  ggtitle("Estimated Effect of Treatments on Support for Political Violence across Levels of Negativity Bias")
negplot2 <- interplot(interfit_negbias2, var1 = "Condition", var2 = "neg_bias_scaled", hist = TRUE, facet_labs = c("American Condition", "Instrumental Condition", "Negative Condition", "Positive Condition")) +
  xlab("Negativity Bias Score") +
  ylab("ANES Questions") +
  geom_hline(yintercept=0, linetype="dashed")
strengthplot <- interplot(interfit_strength, var1 = "Condition", var2 = "strength_scaled", hist = TRUE, facet_labs = c("American Condition", "Instrumental Condition", "Negative Condition", "Positive Condition")) +
  xlab("Party Strength Score") +
  ylab("Kalmoe & Mason Questions") +
  geom_hline(yintercept=0, linetype="dashed") +
  ggtitle("Estimated Effect of Treatments on Support for Political Violence across Levels of Partisan Strength")
strengthplot2 <- interplot(interfit_strength2, var1 = "Condition", var2 = "strength_scaled", hist = TRUE, facet_labs = c("American Condition", "Instrumental Condition", "Negative Condition", "Positive Condition")) +
  xlab("Party Strength Score") +
  ylab("ANES Questions") +
  geom_hline(yintercept=0, linetype="dashed")
ddplot <- interplot(interfit_dd, var1 = "Condition", var2 = "dd_scaled", hist = TRUE, facet_labs = c("American Condition", "Instrumental Condition", "Negative Condition", "Positive Condition")) +
  xlab("Dark Triad Score") +
  ylab("Kalmoe & Mason Questions") +
  geom_hline(yintercept=0, linetype="dashed") +
  ggtitle("Estimated Effect of Treatments on Support for Political Violence across Levels of Dark Triad Score")
ddplot2 <- interplot(interfit_dd2, var1 = "Condition", var2 = "dd_scaled", hist = TRUE, facet_labs = c("American Condition", "Instrumental Condition", "Negative Condition", "Positive Condition")) +
  xlab("Dark Triad Score") +
  ylab("ANES Questions") +
  geom_hline(yintercept=0, linetype="dashed")

inter1 <- ggarrange(negplot, negplot2, nrow = 2)
inter2 <- ggarrange(strengthplot, strengthplot2, nrow = 2)
inter3 <- ggarrange(ddplot, ddplot2, nrow = 2)

# Produce Figure A2
inter1
# Produce Figure A3
inter2
# Produce Figure A4
inter3










```

# Tables

```{r}

# Model Names
models <- list(
  "Treatment Effects" = fit2,
  "Treatments Effects (Controlled)" = fitAll2,
  "Interaction between Party and Condition" = interfit_party2,
  "Interaction between Dark Triad Score and Condition" = interfit_dd2,
  "Interaction between Negativity Bias and Condition" = interfit_negbias2,
  "Treatment Effects" = fit,
  "Treatments Effects (Controlled)" = fitAll,
  "Interaction between Party and Condition" = interfit_party,
  "Interaction between Dark Triad Score and Condition" = interfit_dd,
  "Interaction between Negativity Bias and Condition" = interfit_negbias
)

# Coefficient Mapping
cm <- c("ConditionAmerican" = "American Condition",
        "ConditionInstrumental" = "Instrumental Condition",
        "ConditionNegative" = "Negative Condition",
        "ConditionPositive" = "Positive Conditon",
        "strength_scaled" = "Partisan Strength",
        "dd_scaled" = "Dark Triad Score",
        "age" = "Age",
        "gender" = "Female",
        "ethnicity" = "Ethnicity",
        "educ" = "Education",
        "PartyIDRepublican party" = "Republican",
        "neg_bias_scaled" = "Negativity Bias",
        "race2" = "Non-White",
        "educ2" = "College Degree",
        "ConditionAmerican:PartyIDRepublican party" = "American Condition * Republican",
        "ConditionInstrumental:PartyIDRepublican party" = "Instrumental Condition * Republican",
        "ConditionNegative:PartyIDRepublican party" = "Negative Condition * Republican",
        "ConditionPositive:PartyIDRepublican party" = "Positive Condition * Republican",
        "ConditionAmerican:dd_scaled" = "American Condition * Dark Triad Score",
        "ConditionInstrumental:dd_scaled" = "Instrumental Condition * Dark Triad Score",
        "ConditionNegative:dd_scaled" = "Negative Condition * Dark Triad Score",
        "ConditionPositive:dd_scaled" = "Positive Condition * Dark Triad Score",
        "ConditionAmerican:neg_bias_scaled" = "American Condition * Negativity Bias",
        "ConditionInstrumental:neg_bias_scaled" = "Instrumental Condition * Negativity Bias",
        "ConditionNegative:neg_bias_scaled" = "Negative Condition * Negativity Bias",
        "ConditionPositive:neg_bias_scaled" = "Positive Condition * Negativity Bias"
        )

cm2 <- c("amer_con" = "Effect of Answering Political Violence Questions before Outcome",
         "pos_con" = "Effect of Answering Political Violence Questions before Outcome",
         "neg_con" = "Effect of Answering Political Violence Questions before Outcome",
         "ins_con" = "Effect of Answering Political Violence Questions before Outcome")

cm2 <- c("amer_con" = "Effect of Answering Political Violence Questions before Outcome",
         "pos_con" = "Effect of Answering Political Violence Questions before Outcome",
         "neg_con" = "Effect of Answering Political Violence Questions before Outcome",
         "ins_con" = "Effect of Answering Political Violence Questions before Outcome",
         "PartyIDRepublican party" = "Republican",
         "strength_scaled" = "Partisan Strength")

cm3 <- c("amId_scaled" = "Relationship to Support for Political Violence",
         "policyfolded_scaled" = "Relationship to Support for Political Violence",
         "neg_scaled" = "Relationship to Support for Political Violence",
         "pos_scaled" = "Relationship to Support for Political Violence")

cm3control <- c("amId_scaled" = "Relationship to Support for Political Violence (Controlled)",
         "policyfolded_scaled" = "Relationship to Support for Political Violence (Controlled)",
         "neg_scaled" = "Relationship to Support for Political Violence (Controlled)",
         "pos_scaled" = "Relationship to Support for Political Violence (Controlled)")

# Table 1: Relationship between scales and support for political violence

tab3control <- modelsummary(models3control, statistic = 'p.value', stars = TRUE, coef_map = cm3control, gof_omit = 'IC|Log|F|AIC|BIC|Log.Lik.') %>%
  add_header_above(c(" " = 1, "ANES Questions" = 4, "Kalmoe & Mason Questions" = 4))

# Produce Table 1
tab3control


# Appendix Tables

# Prepare Table A1: Summary Statistics
summaries <- df %>% 
  dplyr::select('American Identity Score' = amId_scaled,
              'Instrumental Partisan Identity Score' = policy_scaled,
                'Negative Partisan Identity Score' = neg_scaled,
                'Positive Partisan Identity Score' = pos_scaled, 
                'Negativity Bias Score' = neg_bias_scaled,
               'Dark Triad Score' = dd_scaled,
                'Political Violence Support (ANES Questions)' = pv_scaled2,
                'Political Violence Support (Kalmoe & Mason Questions)' = pv_scaled)


# Produce Table A1 
datasummary_skim(data = summaries)


# Full Models with Interactions
# tab <- modelsummary(models, statistic = 'p.value', stars = TRUE, coef_map = cm, gof_omit = 'IC|Log|F|AIC|BIC|Log.Lik.') %>% 
#  add_header_above(c(" " = 1, "ANES Questions" = 5, "Kalmoe & Mason Questions" = 5))

# Table A2: Full Models (All Conditions)

models.nointer <- list(
  "Treatment Effects" = fit2,
  "Treatments Effects (Controlled)" = fitAll2,
  "Treatment Effects" = fit,
  "Treatments Effects (Controlled)" = fitAll
)

tab_nointer <- modelsummary(models.nointer, statistic = 'p.value', stars = TRUE, coef_map = cm, gof_omit = 'IC|Log|F|AIC|BIC|Log.Lik.') %>% 
  add_header_above(c(" " = 1, "ANES Questions" = 2, "Kalmoe & Mason Questions" = 2))

# Produce Table A2
tab_nointer


# Table A3: Full Models (Control Condition Respondents)

df_control <- filter(df, Condition == "Control")

fitAll_control <- lm(pv_scaled ~ strength_scaled + age +
               gender + race + educ + PartyID + dd_scaled + neg_bias_scaled, data = df_control)
fitAll2_control <- lm(pv_scaled2 ~ strength_scaled + age +
                gender + race + educ + PartyID + dd_scaled + neg_bias_scaled, data = df_control)

models.nointer_control <- list(
  "Coefficients" = fitAll2_control,
  "Coefficients" = fitAll_control
)

tab.nointer_control <- modelsummary(models.nointer_control, statistic = 'p.value', stars = TRUE, coef_map = cm, gof_omit = 'IC|Log|F|AIC|BIC|Log.Lik.') %>%
  add_header_above(c(" " = 1, "ANES Questions" = 1, "Kalmoe & Mason Questions" = 1))

#Produce Table A3
tab.nointer_control


# Table A4a
tab2 <- modelsummary(models2, statistic = 'p.value', stars = TRUE, coef_map = cm2, gof_omit = 'IC|Log|F|AIC|BIC|Log.Lik.')

tab2


# Table A4b
tab2 <- modelsummary(models2b, statistic = 'p.value', stars = TRUE, coef_map = cm2, gof_omit = 'IC|Log|F|AIC|BIC|Log.Lik.')

tab2




# Additional Table: Relationship between scales and support for political violence (without controls)

# tab3 <- modelsummary(models3, statistic = 'p.value', stars = TRUE, coef_map = cm3, gof_omit = 'IC|Log|F|AIC|BIC|Log.Lik.') %>%
#                     add_header_above(c(" " = 1, "ANES Questions" = 4, "Kalmoe & Mason Questions" = 4))

# tab3

#Correlation Plot
# datasummary_correlation(summaries)




```
